using Microsoft.Xna.Framework;

namespace Xfinity.Engine
{
    /// <summary>
    /// A simple component that measures the frames per second.
    /// </summary>
    public class FpsCounter : GameComponent
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FpsCounter"/> class.
        /// </summary>
        /// <param name="game">Game the game component should be attached to.</param>
        public FpsCounter(Game game)
            : base(game)
        {
            
        }
        /// <summary>
        /// Called when the GameComponent needs to be updated.  Override this method with component-specific update code.
        /// </summary>
        /// <param name="gameTime">Time elapsed since the last call to Microsoft.Xna.Framework.GameComponent.Update(Microsoft.Xna.Framework.GameTime)</param>
        public override void Update(GameTime gameTime)
        {
            fps = (1000/gameTime.ElapsedRealTime.TotalMilliseconds);
        }
        private static double fps;

        /// <summary>
        /// Gets the FPS.
        /// </summary>
        /// <value>The FPS.</value>
        public static double Fps
        {
            get { return fps; }
        }

    }
}
